package beans;

import net.sourceforge.stripes.util.HtmlUtil;

/**
 * MesssageBean class represented one row in table message in db.
 * For easier work is there atribute user which is not in db.
 * @author Tomas CASTA
 */
public class MessageBean {
    /** message id */
    private int id;
    /** messages id where message is, one messages is forum */
    private int idForum;
    /** message author id */
    private int idUser;
    /** time of posting */
    private String postedAt;
    /** text of message */
    private String text;
    /** user who posted it */
    private UserBean user;

    /**
     * Constructor.
     * @param id int message id
     * @param idForum int messages id where message is
     * @param idUser int message author id
     * @param postedAt String time of posting
     * @param text String text of message 
     */
    public MessageBean(int id, int idForum, int idUser, String postedAt, String text) {
        this.id = id;
        this.idForum = idForum;
        this.idUser = idUser;
        this.postedAt = postedAt;
        this.text = HtmlUtil.encode(text);
    }

    /**
     * Constructor.
     * @param id int message id
     * @param idForum int messages id where message is
     * @param idUser int message author id
     * @param postedAt String time of posting
     * @param text String text of message
     * @param user UserBean user who posted it
     */
    public MessageBean(int id, int idForum, int idUser, String postedAt, String text, UserBean user) {
        this.id = id;
        this.idForum = idForum;
        this.idUser = idUser;
        this.postedAt = postedAt;
        this.text = HtmlUtil.encode(text);
        this.user = user;
    }

    public void setUser(UserBean user) {
        this.user = user;
    }

    public UserBean getUser() {
        return user;
    }

    public int getId() {
        return id;
    }

    public int getIdForum() {
        return idForum;
    }


    public int getIdUser() {
        return idUser;
    }

    public String getPostedAt() {
        return postedAt;
    }

    public String getText() {
        return text;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setIdForum(int idForum) {
        this.idForum = idForum;
    }

   

    public void setIdUser(int idUser) {
        this.idUser = idUser;
    }

    public void setPostedAt(String postedAt) {
        this.postedAt = postedAt;
    }

    public void setText(String text) {
        this.text = text;
    }

    

}
